package com.chen.apply.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.common.pojo.entity.Plan;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface PlanMapper extends BaseMapper<Plan> {

    /**
     * 根据申请ID计算总预算金额
     * @param applyId 申请ID
     * @return 总预算金额（单位：分）
     */
    @Select("SELECT COALESCE(SUM(budget_amount), 0) FROM plan WHERE apply_id = #{applyId}")
    Integer selectTotalBudgetByApplyId(@Param("applyId") Integer applyId);
}
